//验证数据库中的用户和密码和手机是否存在
const User = {

	//查询用户名|手机号
	queryUserName( option ){
		
		return "select * from user where name = '"+option.userName+"' or phone = '"+option.userName+"'  ";

	},
	//查询用户名|手机号===》密码
	queryUserPwd( option ){

		return "select * from user where (name = '"+option.userName+"' or phone = '"+option.userName+"') and password = '"+option.userPwd+"' ";

	},
	//增加一条用户记录
	insertData( option ){
		
		let userName = option.userName;
		//引入插件
		let jwt = require('jsonwebtoken');
		//用户信息
		let payload = {name:userName};
		//口令==》品牌
		let secret = 'xiaoluxian';
		let token = jwt.sign(payload, secret);
		
		return 'insert into user (name,phone,password,nick,imgUrl,token) values ("","'+option.userName+'","666666","'+option.userName+'","img/nick.png","'+token+'")';

	}
}

exports = module.exports = User;